<?
require("page.inc");
require("database.inc");
$search_result=new page();
$search_type=$_POST['search_type'];
$searchterm=trim($_POST['searchterm']);
$content="";
if(!get_magic_quotes_gpc()){
	$searchterm=addslashes($searchterm);
	$search_type=addslashes($search_type);
	}
if($searchterm==''){
	$search_result->content="Please Input The Search Iterm";
	$search_result->display();
	return;
	}
@$con=new mysqli($lu_host,$lu_user,$lu_psw,$lu_db);
//或者上面两行写成 $con=new sqli('localhost','lustudy_web','123456',';lustudy')
if(mysqli_connect_error()){
	$search_result->content= "ERROR:Can not connect database.Please Try Again Later";
	$search_result->display();
	exit;
	}
@$con->select_db($lu_db);
$sqlstr="select * from books where ".$search_type." like '%".$searchterm."%'";//该语句不需要分号
//echo $sqlstr;
$web_reasult=$con->query($sqlstr);
$reasult_num=$web_reasult->num_rows;
$content.= "Number of books found : ".$reasult_num."<br /><br />";
//if($reasult_num==0){exit;}	
for($i=0;$i<$reasult_num;$i++){//什么时候用逗号什么时候用分号来着
	$row=$web_reasult->fetch_assoc();
	$content.= ($i+1)." Title: ".$row['title']."<br />
	Athor : ".$row['author']."<br />
	ISBN : ".$row['isbn']."<br />
	Price : ".$row['price']."<br /><br />";
	}
$content.="<a href=\"search.php\"><font color=\"#330000\">返回</font></a><br /><br />";
$web_reasult->free();
$con->close();
$search_result->content=$content;
$search_result->display();





?>